package cn.itcast.config;/*
 * @author: Hayabusa
 * @date: 2022/2/3 21:33
 * @Description: 广播模式配置类
 * @Email:2682557218@qq.com
 */

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Configuration
public class FanoutConfig {
    //    声明FanoutExchange交换机
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("hayabusa.fanout");
    }

    @Bean
    //    声明第一个队列
    public Queue fanoutQueue1() {
        return new Queue("fanout.queue1");

    }

    @Bean
    //    声明第二个队列
    public Queue fanoutQueue2() {
        return new Queue("fanout.queue2");

    }
    @Bean
    //    绑定队列1和交换机
    public Binding bindingQueue1(Queue fanoutQueue1, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(fanoutQueue1).to(fanoutExchange);
    }

    @Bean
    //    绑定队列2和交换机
    public Binding bindingQueue2(Queue fanoutQueue2, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(fanoutQueue2).to(fanoutExchange);
    }

}
